home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
begincpp.zip
/
#7_VER2.CPP
< prev
next >
Wrap
Text File
|
1990-08-03
|
648b
|
41 lines
void *malloc(unsigned);
int free (void *);
struct tag_name { //tag_name is also a type in C++
int i;
float f;
};
class class_one {
tag_name t; //implicitly declare class_one *this;
public:
class_one (int i0 = 0, float f0 = 0) { t.i = i0, t.f = f0; }
class_one *tag() { return this; }
};
class class_two {
public:
class_two (unsigned);
~class_two();
};
class_two::class_two (unsigned size)
{
this = (class_two *) malloc (size);
}
class_two::~class_two ()
{
free (this);
this = 0;
}
main()
{
class_one c1 (1, 1.1), cc1;
class_two c2 (sizeof(class_two)) ;
cc1 = *c1.tag();
}